package com.xw.bo.ks.controller.no;

import com.xw.bo.ks.aspect.CacheControllerCodeInterface;
import com.xw.bo.ks.entity.CacheInfo;
import com.xw.bo.ks.entity.common.CodeCommon;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author： XW -> ~
 * @create： 2024/6/6 17:22
 */
@RestController
@RequestMapping("/cache")
public class CacheInfoController {

    @Resource
    private CacheControllerCodeInterface cacheControllerInfoService;

    @PostMapping(value = "/addCache")
    public String addCache(@RequestBody CacheInfo cacheInfo) {
        cacheControllerInfoService.addCache(cacheInfo.getInfo(),7200L);
        return cacheInfo.getInfo() + "=ok";
    }

    @PostMapping(value = "/closeCache")
    public String closeCache(@RequestBody CacheInfo cacheInfo) {
        cacheControllerInfoService.openCloseCache(cacheInfo.getInfo(), CodeCommon.ENABLE_CLOSE);
        return cacheInfo.getInfo() + "=ok";
    }

    @GetMapping(value = "/loadCacheByMysql")
    public String loadCacheByMysql() {
        cacheControllerInfoService.readMysqlCache();
        return "ok";
    }

}
